# -------------------------------------------------
# DEMOENGINE_ROOT/CmakeLists.txt 
# -------------------------------------------------

PROJECT(DENG)

SET( CMAKE_DEBUG_POSTFIX  "")

SET (LIBRARY_OUTPUT_PATH    ${DENG_BINARY_DIR}/bin/ CACHE INTERNAL "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${DENG_BINARY_DIR}/bin/ CACHE INTERNAL "Single output directory for building all executables.")

###################################################
# Find OSG

SET( OSG_INSTALL_DIR "" CACHE PATH "OpenSceneGraph Installation Directory" )
SET( OSG_INCLUDE_DIR   ${OSG_INSTALL_DIR}/include  )
SET( OSG_LIB_DIR   ${OSG_INSTALL_DIR}/lib  )

IF(NOT EXISTS ${OSG_INSTALL_DIR})
  MESSAGE(ERROR " OSG_INSTALL_DIR not exist - check your settings")
ELSEIF(NOT EXISTS ${OSG_INSTALL_DIR})
  IF(NOT EXISTS ${OSG_INCLUDE_DIR})
	  MESSAGE(ERROR " OSG_INCLUDE_DIR not exist - check your settings")
	ENDIF(NOT EXISTS ${OSG_INCLUDE_DIR})
	IF(NOT EXISTS ${OSG_LIB_DIR})
	  MESSAGE(ERROR " OSG_LIB_DIR not exist - check your settings")
	ENDIF(NOT EXISTS ${OSG_LIB_DIR})
ENDIF(NOT EXISTS ${OSG_INSTALL_DIR})

###################################################
# Find PYTHON
# 
# - PYTHON_INCLUDE_PATH  - C:/Python24/include
# - PYTHON_LIBRARY       - C:/Python24/libs/python24.lib
# - PYTHON_SITE_PACKAGES - C:/Python24/lib/site-packages

FIND_PACKAGE(PythonLibs)

GET_FILENAME_COMPONENT( PYTHON_DIR ${PYTHON_INCLUDE_PATH} PATH )
SET( PYTHON_SITE_PACKAGES ${PYTHON_DIR}/Lib/Site-Packages  )

IF(NOT EXISTS ${PYTHON_SITE_PACKAGES})
  MESSAGE(ERROR " alert: ${PYTHON_SITE_PACKAGES} not exist")
ENDIF(NOT EXISTS ${PYTHON_SITE_PACKAGES})

SET( INST_DIR ${PYTHON_SITE_PACKAGES}/demoEnginePython )
FILE(MAKE_DIRECTORY ${INST_DIR} )

###################################################

ADD_SUBDIRECTORY(SRC)

ADD_SUBDIRECTORY(TEST)

ADD_SUBDIRECTORY(SWIG)

#-----------------------------------------------------------------------------
# Write the list of variables and their values that are defined by CMake 
# when running this CMakeList file
#-----------------------------------------------------------------------------
IF (DEBUG_MESSAGES)
  GET_CMAKE_PROPERTY(VARS VARIABLES)
  FOREACH(var ${VARS})
  	FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt 
  							"${var} \"${${var}}\"\n")
  ENDFOREACH(var ${VARS})
ENDIF (DEBUG_MESSAGES)

